package cn.jit.bo;

import java.util.ArrayList;

public class Page<T> {
	private Integer whichPage;
	
	private Integer eachPageNum;
	
	private Integer totalPages;
	
	private Integer currentPageCount;
	
	private Integer totalCount;
	
	private ArrayList<T> data;
	
	public Page() {
		
	}
	
	public Page(Integer whichPage, Integer eachPageNum, Integer totalPages, Integer totalCount) {
		if (whichPage == 1) {
			if (totalPages == 1) {
				currentPageCount = totalCount;
			} else {
				currentPageCount = eachPageNum;
			}	
		} else if (whichPage == totalPages) {
			currentPageCount = totalCount - (totalPages - 1) * eachPageNum;
		} else {
			currentPageCount = eachPageNum;
		}		
	}
	
	public Integer getWhichPage() {
		return whichPage;
	}

	public void setWhichPage(Integer whichPage) {
		this.whichPage = whichPage;
	}

	public Integer getEachPageNum() {
		return eachPageNum;
	}

	public void setEachPageNum(Integer eachPageNum) {
		this.eachPageNum = eachPageNum;
	}

	public Integer getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(Integer totalPages) {
		this.totalPages = totalPages;
	}

	public Integer getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(Integer totalCount) {
		this.totalCount = totalCount;
	}
	
	public Integer getCurrentPageCount() {
		return currentPageCount;
	}

	public void setCurrentPageCount(Integer currentPageCount) {
		this.currentPageCount = currentPageCount;
	}
	
	public void setCurrentPageCount(Integer whichPage, Integer eachPageNum, Integer totalPages, Integer totalCount) {
		if (whichPage == 1) {
			if (totalPages == 1) {
				currentPageCount = totalCount;
			} else {
				currentPageCount = eachPageNum;
			}	
		} else if (whichPage == totalPages) {
			currentPageCount = totalCount - (totalPages - 1) * eachPageNum;
		} else {
			currentPageCount = eachPageNum;
		}		
	}
	
	public ArrayList<T> getData() {
		return data;
	}

	public void setData(ArrayList<T> data) {
		this.data = data;
	}

	

	@Override
	public String toString() {
		return "Page [whichPage=" + whichPage + ", eachPageNum=" + eachPageNum + ", totalPages=" + totalPages
				+ ", currentPageCount=" + currentPageCount + ", totalCount=" + totalCount + ", data=" + data + "]";
	}

	

	
	
}
